package com.latefly.skewwork.ui.page.practice

import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

@Composable
fun IntrinsicsDemo(modifier: Modifier = Modifier) {

    //由于组件不知道内容的最终高度所以需要让行组件计算出高度值然后限定分割线的长度
    Row(modifier = modifier.height(IntrinsicSize.Min)) {
        Text(
            text = "Hi",
            modifier = Modifier
                .weight(1f)
                .padding(start = 10.dp)
                .wrapContentWidth(Alignment.Start)

        )
        Divider(
            color = Color.Black,
            modifier = Modifier
                .fillMaxHeight()
                .width(1.dp)
        )
        Text(
            text = "End",
            modifier = Modifier
                .weight(1f)
                .padding(end = 10.dp)
                .wrapContentWidth(Alignment.End)

        )
    }
}